<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>:only-child</title>
    <style>
    h1:only-child {
        color: yellowgreen;
    }
    div p:only-child {
        color: blueviolet
    }
    </style>
</head>
<body>
    <h1>:only-child</h1>
    <div>
        <p>CSS伪类:only-child代表了属于某个父元素的唯一一个子元素.等效的选择器还可以写成 :first-child:last-child或者:nth-child(1):nth-last-child(1),当然,前者的权重会低一点.</p>
    </div>
</body>
</html>
